package org.example.common.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DataSourceConfig {

    // 主数据源
    @Bean(name = "primaryDS")
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource.primary")
    public DataSource primaryDataSource() {
        return new HikariDataSource(); // 使用连接池
    }

    // 法律援助数据源
    @Bean(name = "caseDS")
    @ConfigurationProperties(prefix = "spring.datasource.secondary")
    public DataSource secondaryDataSource() {
        return new HikariDataSource();
    }
    // 聊天数据源
    @Bean(name = "chatDS")
    @ConfigurationProperties(prefix = "spring.datasource.chat")
    public DataSource chatDataSource() {
        return new HikariDataSource();
    }
}
